package cn.tx.user.feign.sentinel;

import cn.tx.pojo.domain.User;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class UserBlockHandler {

    // 参数必须加上BlockException 不然报错
    public static User getByIdBlockHandler(@PathVariable("id") Long id, BlockException e) {
        e.printStackTrace();
        return new User(-1L,"限流","---限流限流---");
    }
    // 参数必须加上BlockException 不然报错
    public static User getUserInfoBlockHandler(@RequestParam Map<String, Object> params, BlockException e) {
        e.printStackTrace();
        return new User(-1L,"限流","---限流限流---");
    }
    // 参数必须加上BlockException 不然报错
    public static List<User> getListUserBlockHandler(BlockException e) {
        e.printStackTrace();
        List<User> userList = new ArrayList<>();
        User user =new User(-1L,"限流","---限流限流---");
        userList.add(user);
        return userList;
    }
}
